package com.ssmsq.multidatabase.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssmsq.multidatabase.entity.SysRole;
import com.ssmsq.multidatabase.mapper.SysRoleMapper;
import com.ssmsq.multidatabase.service.SysRoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.UUID;

/**
 * @author sss
 */
@DS("slave_2")
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    @Override
    public boolean saveOne(Integer b, Date date) {
        boolean save = false;
        try {
            SysRole sysRole = new SysRole();
            sysRole.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            sysRole.setSysRoleName("jsfcs_" + date);

             save = save(sysRole);
            if(b != null) {
                int c = 1/0;
            }
        } catch (Exception e) {
            throw e;
        }
        return save;
    }
}
